import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

export type UploadResult = {
  errno: number;
  data?: {
    url?: string;
    alt?: string;
    href?: string;
    poster?: string;
  };
  message?: string;
};

export const uploadImage = (data?: object) => {
  return http.request<UploadResult>("post", baseUrlApi("uploadImage"), {
    data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

export const uploadVideo = (data?: object) => {
  return http.request<UploadResult>("post", baseUrlApi("uploadVideo"), {
    data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

export const uploadModule = (data?: object) => {
  return http.request<UploadResult>("post", baseUrlApi("uploadModule"), {
    data,
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};
